package com.its.common.config;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.env.EnvironmentPostProcessor;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.core.env.MapPropertySource;
import org.springframework.core.env.PropertySource;

import java.util.HashMap;

/**
 * @Author xiaxp
 * @Date 3/9/22 15:12
 * @Description 获取系统错误信息
 */
public class ServerErrorEnvSetting implements EnvironmentPostProcessor {
    @Override
    public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) {
        HashMap<String, Object> map = new HashMap<>(4);
        map.put("server.error.include-exception", "true");
        map.put("server.error.include-message", "always");
        map.put("server.error.includeException", "true");
        map.put("server.error.includeMessage", "always");
        PropertySource source = new MapPropertySource("ServerErrorEnvExtend", map);
        environment.getPropertySources().addLast(source);
    }
}
